package com.resou.reader.reader.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.resou.reader.R;

/**
 * 阅读器下架页面
 */
public class BookUnShelfView extends LinearLayout {
    TextView tvRetry;
    ImageView ivIcon;
    TextView tvInfo;
    RelativeLayout rlUnShelf;

    public BookUnShelfView(Context context) {
        super(context);
        initView();
    }

    public BookUnShelfView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    private void initView() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.bookunshefview, this);
        rlUnShelf = view.findViewById(R.id.rlUnShelf);
        tvRetry = view.findViewById(R.id.tvRetry);
        ivIcon = view.findViewById(R.id.ivIcon);
        tvInfo = view.findViewById(R.id.tvInfo);
    }

    /**
     * 获取重新拉去的视图
     */
    public TextView getRetry() {
        return tvRetry;
    }

    /**
     * 设置icon
     *
     * @param icon
     */
    public void setIcon(int icon) {
        ivIcon.setBackgroundResource(icon);
    }

    /**
     * 字体颜色
     *
     * @param icon
     */
    public void setTextColor(int icon) {
        tvInfo.setTextColor(getResources().getColor(icon));
    }

    /**
     * 容器高度
     */
    public int getUnshelfHeight() {
        return rlUnShelf.getMeasuredHeight();
    }

    /**
     * 容器宽度度
     */
    public int getUnshelfWidth() {
        return rlUnShelf.getMeasuredHeight();
    }
}
